package debut.peinture;

import android.app.Dialog;
import android.app.DialogFragment;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class FragApropos extends DialogFragment {
	private View principale;
	
	@Override
    public View onCreateView(LayoutInflater inflateur, ViewGroup container, Bundle sauveEtat) {
		principale = inflateur.inflate(R.layout.fragmentapropos, container, false);
		final Dialog dialogue = this.getDialog();
		dialogue.setTitle(principale.getContext().getResources().getString(R.string.app_name));
		try {
			((TextView)principale.findViewById(R.id.tvapropos)).setText(
					"Version : " + principale.getContext().getPackageManager().getPackageInfo("debut.peinture", 0).versionName + "\n"
					+ "Code : " + principale.getContext().getPackageManager().getPackageInfo("debut.peinture", 0).versionCode);
		} catch (NameNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		((Button)principale.findViewById(R.id.boutonapropos)).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View vue) {
				dialogue.dismiss();
			}
		});
		return principale;
	}
}
